package com.xiaoq.order;

import com.alibaba.dubbo.config.annotation.Reference;
import com.xiaoq.schedule.order.IOrderScheduleApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * Created by chenjh on 2018/3/3.
 */
@Component
public class OrderTask {

    private static final Logger LOGGER = LoggerFactory.getLogger(OrderTask.class);

    @Reference(interfaceClass=IOrderScheduleApi.class, check=false, version="1.0.0")
    private IOrderScheduleApi orderScheduleApi;

    /**
     * 取消超时未支付的购票订单
     */
    @Scheduled(cron="0 0/3 * * * ?")
    public void cancelOverTimeNotPay4TicketOrder(){
        orderScheduleApi.cancelOverTimeNotPay4TicketOrder();
    }

    /**
     * 取消超时未支付的预约讲解员订单
     */
    /*每120秒执行一次*/
    @Scheduled(fixedRate = 120000)
    public void cancelOverTimeNotPay4InterpreterOrder(){
        orderScheduleApi.cancelOverTimeNotPay4InterpreterOrder();
    }

    /**
     *  优惠券小米推送
     */
    /*每100秒执行一次*/
    //@Scheduled(fixedRate = 20000)
    //@Scheduled(cron="0 30 13 * * ?")  每天13:30触发
    @Scheduled(cron="0 0 8 * * ?")   //每天早上6点触发
    //@Scheduled(cron="0 0/3 * * * ?")
    public void pushCouponMessage4QuickExpired(){
        orderScheduleApi.pushCouponMessage4QuickExpired();
    }


    @Scheduled(cron="0 0/2 * * * ?")
    public void updateUserFrom4ShopOrders(){
        orderScheduleApi.updateUserFrom4ShopOrders();
    }

}
